package com.snopy.designPattern.structure.flyweight;

import com.snopy.designPattern.structure.flyweight.impl.MidgetCar;
import com.snopy.designPattern.structure.flyweight.impl.SprintCar;
import lombok.extern.slf4j.Slf4j;

/**
 * @author snopy
 * @version 1.0.0
 * @classname FlyWeightPatternDemo
 * @description 享元模式
 * @email 77912204@qq.com
 * @date 2022/03/03 15:53
 */
@Slf4j
public class FlyWeightPatternDemo {
    public static void main(String[] args) {
        Integer num = new Integer(1);
        Integer.valueOf("1");

        RaceCarClient[] raceCars = {new RaceCarClient("Midget"),
                                    new RaceCarClient("Midget"),
                                    new RaceCarClient("Midget"),
                                    new RaceCarClient("Sprint"),
                                    new RaceCarClient("Sprint"),
                                    new RaceCarClient("Sprint")};
        raceCars[0].moveCar(29, 3112);
        raceCars[1].moveCar(39, 2002);
        raceCars[2].moveCar(49, 1985);
        raceCars[3].moveCar(59, 2543);
        raceCars[4].moveCar(69, 2322);
        raceCars[5].moveCar(79, 2135);
        log.info("Midget Car Instances: " + MidgetCar.num);
        log.info("Sprint Car Instances: " + SprintCar.num);
    }
}
